package org.example.huawei;

/**
 * @author Yyming
 * @version 10.0
 * Created by Yyming on 2021/1/9
 */
public class Main1 {

    public static void main(String[] args) {
        int[] nums = {1,3,1};
        System.out.println(findElement(nums));
    }


    private static int findElement(int[] nums) {
        int result = nums[0];
        int count = 1;
        for (int i = 1; i < nums.length; i++) {
            int temp = nums[i];
            if (count == 0) {
                result = temp;
                count++;
                //
                continue;
            }
            count += (result == temp ? 1 : -1);
        }
        return result;
    }
}
